package kr.co.redbean.frame
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import kr.co.redbean.store.IObjectInfo;
	
	public class PopupFrame extends MainFrame implements IFrame
	{
		private var _currentFocus:String;
		protected var _curObj:DisplayObject;
		
		public function PopupFrame()
		{
			super();
			
			addEventListener(Event.ADDED_TO_STAGE, setPlacement);
		}
		
		public function doSetupMotion(objectInfo:IObjectInfo):void {
			
		}
		
		public function doProgressMotion(bytesLoaded:uint, bytesTotal:uint):void {
		}
		
		public function doCompleteMotion(displayObject:DisplayObject):void {
		}
		
		public function setPlacement($e:Event=null):void {
			removeEventListener(Event.ADDED_TO_STAGE, setPlacement);
			
			setPosition();
		}
		
		private function setPosition():void {
			x = int(posF.left);
			y = int(posF.top);
		}
		
		public function addObject(obj:DisplayObject):void {
//			obj.alpha = 0;
			obj.addEventListener(Event.CLOSE, onClose);
			addChild(obj);
			setPosition();
		}
		
		private function onClose($e:Event):void {
			// 로딩됐었던 외부swf를 제거함
			removeChild(_curObj);
			_currentFocus = null;
		}
		
		public function get currentFocus():String
		{
			return _currentFocus;
		}

		public function set currentFocus(value:String):void
		{
			_currentFocus = value;
		}

	}
}